package com.example.farmer.Entity;

public class ClassPost {
    private int id;
    private String title;
    private String content;
    private String imageUri;
    private String type;
    private String address;
    private boolean hasImage; // 指示是否有关联的图片

    // Constructor, getters and setters
    public ClassPost(int id, String title, String content, String imageUri, String type, String address) {
        this.id = id;
        this.title = title;
        this.content = content;
        this.imageUri = imageUri;
        this.type = type;
        this.address = address;
    }
    public ClassPost (){

    }

    public ClassPost(int id, String imageUri,String title) {
        this.id = id;
        this.imageUri = imageUri;
        this.title = title;
    }

    // setters and getters

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getImageUri() {
        return imageUri;
    }

    public void setImageUri(String imageUri) {
        this.imageUri = imageUri;
        this.hasImage = (imageUri != null && !imageUri.isEmpty());
    }

    public boolean hasImage() {
        return this.hasImage = (imageUri != null && !imageUri.isEmpty());
    }
    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }
    // 检查帖子是否有图片


    @Override
    public String toString() {
        return "ClassPost{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", imageUri='" + imageUri + '\'' +
                ", type='" + type + '\'' +
                ", address='" + address + '\'' +
                ", hasImage=" + hasImage +
                '}';
    }
}